//
//  LSVideoScreenshotEditToolBarView.m
//  lightSpot
//
//  Created by lightSpot on 2021.
//  Copyright ©2021年 lightSpot. All rights reserved.
//

#import "LSVideoScreenshotEditToolBarView.h"

@implementation LSVideoScreenshotEditToolBarView

+ (id)instanceView {
    NSArray* nibView =  [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
    return [nibView objectAtIndex:0];
}

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setData:(id)data delegate:(id)delegate {
    _delegate = delegate;
    if ([data isKindOfClass:[LSVideoScreenshotEditToolBarViewModel class]]) {
        LSVideoScreenshotEditToolBarViewModel *model = data;
        _mySlider.minimumValue = 0;
        _mySlider.maximumValue = model.max - 1;
        _mySlider.value = 1.0 * model.index;
        _minLabel.text = @"00:00";
        _maxLabel.text = model.duration;
    }
}

- (IBAction)buttonAction:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(videoScreenshotEditToolBarView:button:)]) {
        [_delegate videoScreenshotEditToolBarView:self button:sender];
    }
}

- (IBAction)sliderValueChangedButtonAction:(UISlider *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(videoScreenshotEditToolBarView:sender:)]) {
        [_delegate videoScreenshotEditToolBarView:self sender:sender];
    }
}

@end


@implementation LSVideoScreenshotEditToolBarViewModel

+ (LSVideoScreenshotEditToolBarViewModel *)ittemModelWithMini:(NSInteger)mini max:(NSInteger)max index:(NSInteger)index duration:(NSString *)duration {
    LSVideoScreenshotEditToolBarViewModel *model = [LSVideoScreenshotEditToolBarViewModel new];
    model.mini = mini;
    model.max = max;
    model.index = index;
    model.duration = kSafeString(duration);
    return model;
}

@end
